package com.liuhe.collections.test1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Test1 {
    public static void main(String[] args) {
        //随机抽取学生姓名
        ArrayList<String> list = new ArrayList<>();
        //添加数据
        Collections.addAll(list, "Jack", "Tom", "Mary", "yi");
        //随机获取
        Random r = new Random();
        int index = r.nextInt(list.size());
        System.out.println(list.get(index));
        //打乱顺序获取
        Collections.shuffle(list);
        System.out.println(list.get(0));
    }
}
